package com.hunanwenli.movie.controller;

import com.hunanwenli.entity.*;
import com.hunanwenli.movie.service.*;
import com.hunanwenli.tool.Tools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @author wanzhenyu
 * @date 2021/5/2 23:15
 */
@Controller
@RequestMapping(value = "/userInfo")
public class UserInfoController {
    @Autowired
    private UserInfoService userInfoService;
    @Autowired
    private RedisService redisService;




   @PutMapping(value = "/putUserInfo/{update}")
   @ResponseBody
   public Boolean putUserInfo(@PathVariable("update")String update){
       UserInfo userInfo = Tools.jsonToPojo(update, UserInfo.class);
       if (Tools.isNullOrEmpty(userInfo)){
           return false;
       }
       String phone = userInfo.getPhone();
       redisService.remove(phone);
       int i = userInfoService.updateByPrimaryKeySelective(userInfo);
       if (i==1){
           String json = Tools.objectToJson(userInfo);
           redisService.put(phone,json);
           return true;
       }else {
           return false;
       }
   }





}
